package com.abc.generator;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.LinearGradientPaint;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.JFrame;

import com.abc.model.ProjectYear;

import de.erichseifert.gral.data.DataSource;
import de.erichseifert.gral.data.DataTable;
import de.erichseifert.gral.plots.BarPlot;
import de.erichseifert.gral.plots.BarPlot.BarRenderer;
import de.erichseifert.gral.ui.InteractivePanel;
import de.erichseifert.gral.util.GraphicsUtils;
import de.erichseifert.gral.util.Insets2D;
import de.erichseifert.gral.util.Location;

import com.abc.model.ReportRepository;
import com.abc.model.Project;
import com.abc.model.PersonYearEffort;


/*
 * gral-core-0.10.jar
 * VectorGraphics2D-0.9.1.jar
 */

public class BarTest extends JFrame {
	Color COLOR1 = new Color( 55, 170, 200);
	
	
	List<String> DaysofWeek = new ArrayList<String>();
	
    public BarTest() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(800, 600);
        // Insert rest of the code here
        
        DaysofWeek.add("Monday");
        DaysofWeek.add("Tuesday");
        DaysofWeek.add("Wednesday");
        DaysofWeek.add("Thursday");
        DaysofWeek.add("Friday");
        DaysofWeek.add("Saturday");
        DaysofWeek.add("Sonday");
        
    }
    
    public void initMyData(int[] dataSrc) {
        DataTable data = new DataTable(Integer.class, Integer.class, String.class);
        for (int i = 0; i < DaysofWeek.size(); i++) {
            data.add(i+1, dataSrc[i], DaysofWeek.get(i).toString());
        }
       setBarPlot(data);
    }
    
    public void setBarPlot(DataSource data) {
    	BarPlot plot = new BarPlot(data);
    	plot.getTitle().setText("Przyklad");
        //getContentPane().add(new InteractivePanel(plot));
     // Format plot
     		plot.setInsets(new Insets2D.Double(40.0, 40.0, 40.0, 40.0));
     		plot.setBarWidth(0.075);

     		// Format bars
     		BarRenderer pointRenderer = (BarRenderer) plot.getPointRenderer(data);
     		pointRenderer.setColor(
     			new LinearGradientPaint(0f,0f, 0f,1f,
     					new float[] { 0.0f, 1.0f },
     					new Color[] { COLOR1, GraphicsUtils.deriveBrighter(COLOR1) }
     			)
     		);
     		pointRenderer.setBorderStroke(new BasicStroke(3f));
     		pointRenderer.setBorderColor(
     			new LinearGradientPaint(0f,0f, 0f,1f,
     					new float[] { 0.0f, 1.0f },
     					new Color[] { GraphicsUtils.deriveBrighter(COLOR1), COLOR1 }
     			)
     		);
     		pointRenderer.setValueVisible(true);
     		pointRenderer.setValueColumn(2);
     		pointRenderer.setValueLocation(Location.CENTER);
     		pointRenderer.setValueColor(GraphicsUtils.deriveDarker(COLOR1));
     		pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));

     		// Add plot to Swing component
     		add(new InteractivePanel(plot));

    }
    
    public static void main(String[] args) {
    	//new LinePlotTest().showInFrame();
    	BarTest frame = new BarTest();
    	double [] results;
    	double suma = 0;
    	//HashMap<String, Project> table = ReportRepository.getProjects();
    	//for (Project project1: ReportRepository.getProjects().values()){
    	//	Set<String> years = project1.projectYears.keySet();
    	//	for(String yy : years) {
    	//		//TODO get
    	//		ProjectYear ppp = project1.projectYears.get(yy);
    	//		String developerID = "dev-2010";
    	//		ppp.getDeveloperEfforts(developerID);
    	//	}
    		
    	//}
    	//int[] dane = {3,5,6,7,8,9,0};
		//frame.initMyData(dane);
        frame.setVisible(true);
    }
}